#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<string.h>

int main()
{
   FILE* pf = fopen("log.txt","w");
   if(pf == NULL)
   {
        perror("fopen");
        return 1;
   }

   char buff[1024];
   const char* mesg = "this is a fread test";

   while(1)
   {
        ssize_t res = fread(buff,strlen(mesg), 1, pf); 
        if(res > 0)
        {
            buff[res] = '\0';
            printf("%s\n",buff);
        }
   }

    
//   const char* mesg = "hello Linux\n";
//    
//   fwrite(mesg,strlen(mesg),1,pf);
//
   fclose(pf);

    return 0;
}
